package com.campus.common.mapper;


import com.campus.common.domain.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ProductMapper{
    @Select("select * from product")
    public List<Product> test();

    @Insert("insert into product(product_id, product_name, price, discount, amount, title, description, img_count, gmt_create, gmt_modified) " +
            "value(#{productId}, #{productName}, #{price}, #{discount}, #{amount}, #{title}, #{description}, #{imgCount}, #{gmtCreate}, #{gmtModified})")
    public int insertProduct(Product product);

    @Update("update product SET product_name = #{productName}, price = #{price}, discount = #{discount}, amount = #{amount}, title = #{title}, " +
            "description = #{description}, img_count = #{imgCount}, gmt_modified = #{gmtModified} where product_id = #{productId}")
    public int updateProduct(Product product);

    @Select("select product_id, product_name, price, discount, amount " +
            "from product where product_id = #{productId}")
    public Product selectProduct(Long productId);

}
